package FollowME;

import java.io.Serializable;

import birdsong.comm.ClientSideMessage;

/**
 * Class that defines the messages from server to client. This class implements
 * the interfaces Serializable and ClientSideMessage
 * 
 * @author Fernando Pereira, Marcos Martins
 * @version 2.0
 */
public class ServerToClientMessage implements ClientSideMessage, Serializable {

	private Type type;
	private String payload;
	private String nickname;

	/**
	 * The ServerToClientMessage Constructor. This constructor receives the type
	 * of message that server wants to send to client Also receives the payload
	 * of that message And the nickname of the destination user.
	 * 
	 * @param type
	 *            , type of message
	 * @param payload
	 *            , payload of message
	 * @param nickname
	 *            , nickname of user
	 */
	public ServerToClientMessage(final Type type, final String payload,
			final String nickname) {

		this.type = type;
		this.payload = payload;
		this.nickname = nickname;
	}

	/**
	 * Gets the type of the message.
	 * 
	 * @return type of the message.
	 */
	@Override
	public Type getType() {
		return type;
	}

	/**
	 * Gets the payload of the message.
	 * 
	 * @return payload.
	 */
	@Override
	public String getPayload() {
		return payload;
	}

	/**
	 * Gets the sender of the message.
	 * 
	 * @return nickname of the sender.
	 */
	@Override
	public String getSendersNickname() {
		return nickname;
	}
}